<#include
        "/common/coms.html"  /> <@layout>
<head>
    <!-- page specific plugin styles -->
    <!-- ace styles -->
    <script src="${ctx}/static/inc/platform/js/ajax.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/cbb/artDialog/skins/blue.css">
    <script src="${ctx}/static/cbb/artDialog/jquery.artDialog.js"></script>
    
</head>
<script>
    function cleankhid(){
        $("#start").attr("value","");
        $("#end").attr("value","");
        var start=$("#start").val();
        var end=$("#end").val();
        $("#grid-table").jqGrid('setGridParam',{
            datatype:'json',
            postData:{  'search_LIKE_lrdate':start,'search_EQ_txdate':end}, //发送数据
            page:1
        }).trigger("reloadGrid"); //重新载入
    }


    /**
     * 删除选中的模型信息
     */
    function dels(obj){
        url = '${ctx}/mb/deletewp/';
        $("#id").attr("value",obj);
        $('#myform').form('submit', {
            url : url,
            onSubmit : function() {
            },
            success : function(data) {
                // 回填页面
                alert(data);
                window.location.reload();
            }
        });
    }
</script>
<body>

<div class="page-content" style="overflow: hidden">

    <div class="row-fluid">
        <div class="span12">
            <form class="form-inline" id="myform">
                <input type="hidden" name="id" id="id">
              <!--   商品名称：<input type="text"  name="search_LIKE_wpmc" id="search_LIKE_wpmc"   class="query "  style="min-height: 24px;width: 140px"      />
                  &nbsp; &nbsp;
                <button id="search_btn" onclick="return false;" class="btn btn-info btn-small"  onclick="queryModel()">
                    <i class="bigger-110"></i>
                    查询
                </button>
                <a href="#"  class="btn btn-danger btn-small bigger-110"   onclick="cleankhid();">取消 </a>
 -->
            </form>
            <!-- PAGE CONTENT BEGINS -->
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.span -->
    </div><!-- /.row-fluid -->
</div><!-- /.page-content -->
<!-- page specific plugin scripts -->

<script src="${ctx}/static/assets/js/bootstrap.min.js"></script>
<script src="${ctx}/static/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
<script src="${ctx}/static/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>
<script src="${ctx}/static/assets/js/markdown/markdown.min.js"></script>
<script src="${ctx}/static/assets/js/markdown/bootstrap-markdown.min.js"></script>

<script>
var name='${name}';
name=encodeURI(name);
    function addlb(){
        var url = '${ctx}/mb/addlb?lbid=${lbid}&name= '+name+'&pid=${pid}' ;
        initArtDialog({url:url, title:'新增模板', width:'95%', height:'80%',lock:true,background: '#EAEAEA'});
    }
    function addwp(){
    	var pid ="${(pid)!}";
    	var lbid="${lbid}";
    	
    	if(pid=="0"){
    		alert("只能在模板下面添加步骤！");
    		return;

    	}
        var url = '${ctx}/mb/addwp?lbid=${lbid}&name='+name+'&pid=${pid}' ;
     //  window.location.href=url;
      initArtDialog({url:url, title:'新增步骤', width:'95%', height:'80%',lock:true,background: '#EAEAEA'});
  }
    function addcy(){
    	var pid ="${(pid)!}";
    	var lbid="${lbid}";
    	
    	if(pid=="0"){
    		alert("只能在模板下面添加内容！");
    		return;
    	}
        var url = '${ctx}/mb/addcy?lbid=${lbid}&name='+name+'&pid=${pid}' ;
		window.open(url,'nwindow','height=1800,width=1800,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no')
    }
    
    function edits(obj){
        var rowData = $("#grid-table").getRowData(obj);
        var  url = '${ctx}/mb/addwp?id=' + rowData.id+'&lbid=${lbid}&name='+name+'&pid=${pid}';
//        window.location.href=url;
        initArtDialog({url:url, title:'修改', width:'95%', height:'80%',lock:true,background: '#EAEAEA'});
    }
    function edit(){
        var lbid='${lbid}';
        if(lbid==0){
            alert("根节点不允许修改！");
        }  else {
            var url = '${ctx}/mb/addlb?lbid=${lbid}&name='+name+'&pid=${pid}&id=${lbid}' ;
            initArtDialog({url:url, title:'修改模板', width:'95%', height:'80%',lock:true,background: '#EAEAEA'});
        }
    }

</script>
<script type="text/javascript">


$("#search_btn").click(function(){

    var search_LIKE_wpmc=$("#search_LIKE_wpmc").val();

    $("#grid-table").jqGrid('setGridParam',{
        url:'${ctx}/mb/query',
        datatype:'json',
        postData:{  'search_LIKE_wpmc':search_LIKE_wpmc}, //发送数据
        page:1
    }).trigger("reloadGrid"); //重新载入
});


jQuery(function($) {
    // 获取编号

    //  jqgrid
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";
    var search_LIKE_wpmc=$("#search_LIKE_wpmc").val();


//    var orgid=$("#orgid").val();

    jQuery(grid_selector).jqGrid({
        datatype: "json", //将这里改为使用JSON数据
        mtype:"POST",
        postData:{  'search_LIKE_wpmc':search_LIKE_wpmc}, //发送数据
        url:'${ctx}/mb/query?search_EQ_lbid=${lbid}&search_NU_type=img',
        height: '60%',
        width:'80%',
        footerrow:false,  //合计数据
        colNames:[ '操作 ','顺序名称','顺序编码','序号',''],
        colModel:[
            {name:'edits',index:'',width:80,sortable:false, resizable:true,formatter: printthis},
            {name:'mbsxmc', width:150,sortable:false},
            {name:'mbbh', width:150,sortable:false},
            {name:'dsporder', width:150,sortable:false},

//          {name:'lrdates',index:'',width:50,sortable:false},

            {name:'id', hidden:true}
        ],
        rownumbers:true,//添加左侧行号
        sortname: 'id',
        sortable: false,
        viewrecords: true, //是否显示行数
        rowNum:30,
        rowList:[10,20,30],
        loadtext: '正在加载数据...',
        loadui : 'block',
        pager : pager_selector,
        altRows: true,
        shrinkToFit: true,

        loadComplete : function() {
            var table = this;
            setTimeout(function(){
                updatePagerIcons(table);
            },
                    0);
        } ,
    //    ondblClickRow: openview,
//
        caption: " <input type='button' onclick='addlb()'  class='btn btn-mini btn-danger' value='新增模板设置'> " +
                "&nbsp;&nbsp;&nbsp;<input type='button' onclick='edit()'  class='btn btn-mini btn-yellow' value='修改模板设置'>" +
                "&nbsp;&nbsp;&nbsp;<input type='button' onclick='addcy()'  class='btn btn-mini btn-yellow' value='新增初页模板内容'>"+
                "&nbsp;&nbsp;&nbsp;<input type='button' onclick='addwp()'  class='btn btn-mini btn-danger' value='新增步骤模板'>  " ,
        autowidth: true

    });

    //按钮
    function printthis(cellvalue,options,rowObject){
        var ids=rowObject.id;
        var buttomHtml= "<a class='green' href=\"javascript:edits('" + ids + "')\" title='修改'><i class='icon-pencil bigger-130'></i></a> &nbsp;&nbsp;" +
                "<a class='red' href=\"javascript:dels('" + ids + "')\" title='删除'><i class='icon-trash  bigger-130'></i></a> </div> ";

//        var buttomHtml="<a href='#' class='btn btn-primary btn-mini ' onclick='opennew()'><i class='icon-print  bigger-125  '>打印</i>  </a>";
        return buttomHtml
    }

    function  openview(rowid,iRow,iCol,e){
    /*     url = '${ctx}/bgRctx/view?id=' + rowid;
        initArtDialog({url:url, title:'查看', width:800, height:500,lock:true,background: '#EAEAEA'}); */
    }


});

function updatePagerIcons(table) {
    var replacement =
    {
        'ui-icon-seek-first' : 'icon-double-angle-left bigger-150',
        'ui-icon-seek-prev' : 'icon-angle-left bigger-150',
        'ui-icon-seek-next' : 'icon-angle-right bigger-150',
        'ui-icon-seek-end' : 'icon-double-angle-right bigger-150'
    };
    $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
        var icon = $(this);
        var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

        if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
    })
}

window.onresize = function  _doResize() {
    var ss = pageSize();
    $("#grid-table").jqGrid('setGridWidth', ss.WinW-10).jqGrid('setGridHeight', ss.WinH-200);
}

function pageSize() {
    var winW, winH;
    if(window.innerHeight) {// all except IE
        winW = window.innerWidth;
        winH = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode
        winW = document.documentElement.clientWidth;
        winH = document.documentElement.clientHeight;
    } else if (document.body) { // other
        winW = document.body.clientWidth;
        winH = document.body.clientHeight;
    }  // for small pages with total size less then the viewport
    return {WinW:winW, WinH:winH};
}

//select2查询列表每次只查数据的前20条



</script>

</body>


</@layout>
